package com.cnctema.easecalendar_weekly_view.activities

import android.app.Application
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.cnctema.easecalendar_weekly_view.database.EventDatabaseDao

/**
 * @ClassName: AddEventViewModelFactory
 * @Description: 添加日历事件类viewModel工厂(类的作用描述)
 * @Author: cnctema
 * @CreateDate: 2020/5/27 23:26
 */
class AddEventViewModelFactory(val application:Application,private val dataSource: EventDatabaseDao):ViewModelProvider.Factory {
    override fun <T : ViewModel?> create(modelClass: Class<T>): T {
        if(modelClass.isAssignableFrom(AddEventViewModel::class.java)){
            return AddEventViewModel(application,dataSource) as T
        }
        throw IllegalArgumentException("UnKnown viewModel class")
    }
}
